import { Injectable } from '@nestjs/common'
import { UserClass, UserModel } from './user.model'
// import { PermissionService } from '../permission/permission.service'

@Injectable()
export class UserService {
  // constructor(private permissionService: PermissionService) {}
  async findOneByUsername(username: string): Promise<UserClass | undefined> {
    // const pers = await this.permissionService.findAll()
    // console.log(pers)

    return await UserModel.findOne({ username })
      .select('+password')
      .select('-__v')
      .exec()
  }

  async deleteManyUsers(ids: string[]): Promise<void> {
    await UserModel.deleteMany({ _id: { $in: ids } })
  }
}
